<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取鼠标位置</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        div {
            width: 200px;
            height: 100px;
            background-color: red;
        }
    </style>
    <script>
        function f1(){
            console.log("鼠标所在的x轴坐标:"+event.clientX);
            console.log("鼠标所在的y轴坐标:"+event.clientY);
        }
    </script>
</head>
<body>
<div onmousemove="f1()"></div>
</body>
</html>